import sys
import os
import shutil

from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget
from PyQt4.QtCore import Qt

import model
import gui

def setUpDb():
    if not os.path.exists('lists.db'):
        shutil.copy('schema.db', 'lists.db')

def setUpApp(app, listWidget, taskWidget):
    # there is still way too much gui here.
    win   = QMainWindow()
    dock  = QDockWidget()

    dock.setWidget(listWidget)

    win.setCentralWidget(taskWidget)
    win.addDockWidget(Qt.BottomDockWidgetArea, dock)

    win.show()
    app.exec_()

def main():
    app = QApplication(sys.argv)

    setUpDb()

    listModel,  taskModel  = model.setUpModels()
    listWidget, taskWidget = gui.setUpGUI(listModel, taskModel)

    setUpApp(app, listWidget, taskWidget)

if __name__ == '__main__':
    main()


